import { createApp } from "vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import App from "./App.vue";
import router from "./router";
import { createPinia } from "pinia";
import i18n from "./i18n";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import en from "element-plus/es/locale/lang/en";
import "./utils/tools/rem";
import { useLocaleStore } from "./store";
// 引入全局公共样式
import "./styles/index.scss";

const pinia = createPinia();
const app = createApp(App);

app.use(pinia);

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
const localeStore = useLocaleStore();
i18n.global.locale.value = localeStore.currentLang || "zh-cn";

app
  .use(ElementPlus, {
    locale: localeStore.currentLang === "zh-cn" ? zhCn : en,
  })
  .use(i18n)
  .use(pinia)
  .use(router)
  .mount("#app");
